﻿doreg.php
		<meta charset="utf-8" />

<?php

   include_once('dbConn.php');
	connect();
//使用$_POST数组获取表单中输入的数据
  $uname = trim($_POST['uname']);  
  $password = $_POST['password'];
  $gender = $_POST['gender'];
  $birthdate = $_POST['birthdate'];
  $hobby = $_POST['hobby']; 
  $degree = $_POST['degree'];
   
   $ntro = $_POST['ntro'];


//输出获取到的数据
  echo "页面跳转成功，您的注册信息如下："."<br>";
  echo "您的姓名是：".$uname."<br>";
  echo "您的密码是：".$password."<br>";
  if ($gender==0) { //需要将性别的整型值转换成对应的字符串输出
  	 echo "您的性别是：男"."<br>";
  }else{
  	 echo "您的性别是：女"."<br>";
  }
    if ($hobby==0) { 
  	 echo "您的爱好是：音乐"."<br>";
  }if($hobby==1){
  	 echo "您的爱好是：篮球"."<br>";
  }
  if($hobby==2){
     echo "您的爱好是：羽毛球"."<br>";
  }
  else{
  	 echo "您的爱好是：交友"."<br>";
  }
  echo "您的生日是：".$birthdate."<br>";
  echo "您的学历是：".$degree."<br>";
  echo "您的介绍是：".$ntro."<br>";
  //插入数据库
    $sql="insert into users(uid,uname,password,gender,birthdate,hobby,degree,ntro) values (0,'$uname','$password','$gender','$birthdate','$hobby','$degree','$ntro')";
   // echo $sql.'<br/>';
   //执行SQL语句
  $result = mysql_query($sql) or die('插入失败！'.mysql_error());
  //判断是否插入成功
  $num = mysql_affected_rows();
  if($num!=1){
  	echo "注册失败！<br/>";
  	echo "返回<a href='reg.html'>返回</a>";	  
  }else{	
	echo "注册成功！<br/>";    
  } 
  //关闭数据库
  mysql_close();  

?>